package com.auxgroup.smarthome.inner.entity;

import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.annotation.CreatedDate;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.PrePersist;
import javax.persistence.Table;
import java.time.Clock;
import java.time.Instant;
import java.time.ZoneId;

/**
 *  多联机集成控制功能列表
 */
@Entity
@Table(name = "multi_integration_control_function_list")
public class MultiFunctionListEntity {
    @Id
    @GeneratedValue(generator = "uuid2")
    @GenericGenerator(name = "uuid2", strategy = "uuid2")
    @Column(length = 36)
    private String funId;

    @Column(columnDefinition = " VARCHAR(128) NOT NULL  COMMENT '名称[唯一]'")
    private String funName;

    @Column(columnDefinition = "VARCHAR(1000) COMMENT '描述'")
    private String funDescribe;

    @Column(columnDefinition = "VARCHAR(1000) COMMENT '主模块图所在url'")
    private String deviceMainUri;

    @Lob
    @Column(columnDefinition = " TEXT COMMENT '功能列表'")
    private String feature;

    @Column(updatable = false)
    @CreatedDate
    protected Long createdAt; // 创建时间，UNIX时间戳，秒

    public String getFunId() {
        return funId;
    }

    public void setFunId(String funId) {
        this.funId = funId;
    }

    public String getFunName() {
        return funName;
    }

    public void setFunName(String funName) {
        this.funName = funName;
    }

    public String getFunDescribe() {
        return funDescribe;
    }

    public void setFunDescribe(String funDescribe) {
        this.funDescribe = funDescribe;
    }

    public String getDeviceMainUri() {
        return deviceMainUri;
    }

    public void setDeviceMainUri(String deviceMainUri) {
        this.deviceMainUri = deviceMainUri;
    }

    public String getFeature() {
        return feature;
    }

    public void setFeature(String feature) {
        this.feature = feature;
    }

    @PrePersist
    public void prePersist() {
        Instant instant = Instant.now(Clock.system(ZoneId.of("Asia/Shanghai")));
        this.createdAt = instant.getEpochSecond();
    }

}
